package com.gy.smartmanagement.base.activity;


import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.gy.smartmanagement.R;
import com.gy.smartmanagement.base.api.ApiServiceComponent;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;

/**
 * 包含toolbar的activity基类
 */
public abstract class BaseToolbarActivity extends BaseActivity {
  @BindView(R.id.title_center)
  protected TextView titleCenter;
  @BindView(R.id.toolbar)
  protected Toolbar toolbar;
  @BindView(R.id.back_iv)
  protected ImageView back_iv;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initFragment(savedInstanceState);
    initToolBar();
  }

  protected void initToolBar() {
    back_iv.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        finish();
      }
    });
  }

  protected ApiServiceComponent getApiServiceComponent() {
    return application.getApiServiceComponent();
  }

  protected void setTitleCenter(String title) {
    titleCenter.setText(title);
  }

  protected abstract void initFragment(Bundle savedInstanceState);

}
